package automation;

import java.util.Random;

public class Window implements IWindow {

    private int id;

    @Override
    public void setID(int id) {
        this.id = id;
    }

    @Override
    public int getID() {
        return this.id;
    }

    @Override
    public boolean equals(IWindow window) {
        if (this.hashCode() == window.hashCode()) {
            return true;
        }
        return false;
    }

    @Override
    public boolean open() {
        boolean failure = (new Random()).nextInt(100) < 7 ? true : false;
        if (!failure) {
            System.out.println(String.format("window %d was opened!", this.id));
        }
        return failure;
    }

    @Override
    public void close() {
        System.out.println(String.format("window %d was closed!", this.id));
    }
}
